Telerik.Web.UI.RadContextMenuEventArgs=function(a){Telerik.Web.UI.RadContextMenuEventArgs.initializeBase(this);
this._domEvent=a||null;
};
Telerik.Web.UI.RadContextMenuEventArgs.prototype={get_domEvent:function(){return this._domEvent;
}};
Telerik.Web.UI.RadContextMenuEventArgs.registerClass("Telerik.Web.UI.RadContextMenuEventArgs",Sys.EventArgs);
Telerik.Web.UI.RadContextMenuShownEventArgs=function(a,b){Telerik.Web.UI.RadContextMenuShownEventArgs.initializeBase(this);
this._targetElement=a;
this._domEvent=b||null;
};
Telerik.Web.UI.RadContextMenuShownEventArgs.prototype={get_targetElement:function(){return this._targetElement;
},get_domEvent:function(){return this._domEvent;
}};
Telerik.Web.UI.RadContextMenuShownEventArgs.registerClass("Telerik.Web.UI.RadContextMenuShownEventArgs",Sys.EventArgs);
Telerik.Web.UI.RadContextMenuCancelEventArgs=function(a,b){Telerik.Web.UI.RadContextMenuCancelEventArgs.initializeBase(this);
this._targetElement=a;
this._domEvent=b;
};
Telerik.Web.UI.RadContextMenuCancelEventArgs.prototype={get_targetElement:function(){return this._targetElement;
},get_domEvent:function(){return this._domEvent;
}};
Telerik.Web.UI.RadContextMenuCancelEventArgs.registerClass("Telerik.Web.UI.RadContextMenuCancelEventArgs",Sys.CancelEventArgs);
Telerik.Web.UI.RadContextMenuShowingEventArgs=function(a,b){Telerik.Web.UI.RadContextMenuShowingEventArgs.initializeBase(this,[a,b]);
};
Telerik.Web.UI.RadContextMenuShowingEventArgs.registerClass("Telerik.Web.UI.RadContextMenuShowingEventArgs",Telerik.Web.UI.RadContextMenuCancelEventArgs);
Telerik.Web.UI.RadContextMenuItemEventArgs=function(b,a,c){Telerik.Web.UI.RadContextMenuItemEventArgs.initializeBase(this,[b,c]);
this._targetElement=a;
};
Telerik.Web.UI.RadContextMenuItemEventArgs.prototype={get_targetElement:function(){return this._targetElement;
}};
Telerik.Web.UI.RadContextMenuItemEventArgs.registerClass("Telerik.Web.UI.RadContextMenuItemEventArgs",Telerik.Web.UI.RadMenuItemEventArgs);
Telerik.Web.UI.RadContextMenuItemCancelEventArgs=function(b,a,c){Telerik.Web.UI.RadContextMenuItemCancelEventArgs.initializeBase(this,[b,c]);
this._targetElement=a;
};
Telerik.Web.UI.RadContextMenuItemCancelEventArgs.prototype={get_targetElement:function(){return this._targetElement;
}};
Telerik.Web.UI.RadContextMenuItemCancelEventArgs.registerClass("Telerik.Web.UI.RadContextMenuItemCancelEventArgs",Telerik.Web.UI.RadMenuItemCancelEventArgs);
(function(){var a=Telerik.Web.UI;
Type.registerNamespace("Telerik.Web.UI");
a.ContextMenuTargetType=function(){throw Error.notImplemented();
};
a.ContextMenuTargetType.prototype={Control:0,Element:1,TagName:2,Document:3};
a.ContextMenuTargetType.registerEnum("Telerik.Web.UI.ContextMenuTargetType");
a.RadContextMenu=function(b){a.RadContextMenu.initializeBase(this,[b]);
this._enableSelection=false;
this._targets=[];
this._targetElements=null;
this._shown=false;
this._scrollWrapElement=null;
this._scroller=null;
this._animatedElement=null;
this._slide=null;
this._collapseAnimationEndedDelegate=null;
this._detached=false;
this._currentTarget=null;
this._flow=a.ItemFlow.Vertical;
};
a.RadContextMenu.contextMenus={};
a.RadContextMenu.hideAll=function(){for(var b in a.RadContextMenu.contextMenus){a.RadContextMenu.contextMenus[b].hide();
}};
a.RadContextMenu._getAllHidden=function(){for(var b in a.RadContextMenu.contextMenus){if(a.RadContextMenu.contextMenus[b]._shown){return false;
}}return true;
};
a.RadContextMenu.prototype={initialize:function(){this.get_element().style.display="block";
this.get_element().style.visibility="hidden";
this._getContextMenuElement().style.display="block";
this._getContextMenuElement().style.visibility="hidden";
a.RadContextMenu.callBaseMethod(this,"initialize");
this._getContextMenuElement().style.display="none";
this._getContextMenuElement().style.visibility="visible";
this._getContextMenuElement().id=this.get_id()+"_detached";
this.get_element().style.display="none";
this.get_element().style.visibility="visible";
this._getContextMenuElement().style.zIndex=this._originalZIndex;
this.get_childListElement().style.cssFloat="left";
a.RadContextMenu.contextMenus[this.get_id()]=this;
this._elementContextMenu=Function.createDelegate(this,this._elementContextMenu);
this._attachShowHandlers();
this._documentClickHandler=Function.createDelegate(this,this._documentClickHandler);
$addHandler(document,"click",this._documentClickHandler);
this._itemClickedHandler=Function.createDelegate(this,this._itemClickedHandler);
this.add_itemClicked(this._itemClickedHandler);
this._initializeAnimation();
this._initializeScroller();
},dispose:function(){if(this._detached){this.attachContextMenu();
}$removeHandler(document,"click",this._documentClickHandler);
this._detachShowHandlers();
this._targetElements=null;
this._contextMenuElement=null;
if(this._collapseAnimationEndedDelegate){if(this._slide){this._slide.remove_collapseAnimationEnded(this._collapseAnimationEndedDelegate);
}this._collapseAnimationEndedDelegate=null;
}if(this._slide){this._slide.dispose();
this._slide=null;
}if(this._scroller){this._scroller.dispose();
this._scroller=null;
}delete Telerik.Web.UI.RadContextMenu.contextMenus[this.get_id()];
a.RadContextMenu.callBaseMethod(this,"dispose");
},repaint:function(){a.RadMenu._adjustRootItemWidth(this.get_id(),this.get_childListElement());
},addTargetElement:function(b){if(b){this._addTargetElement(b);
var c=$telerik.isOpera?"mousedown":"contextmenu";
$addHandler(b,c,this._elementContextMenu);
}},removeTargetElement:function(b){if(!b){return;
}var c=$telerik.isOpera?"mousedown":"contextmenu";
if(Array.remove(this._targetElements,b)){$removeHandler(b,c,this._elementContextMenu);
}},_initializeEventMap:function(){this._eventMap.initialize(this,this._getContextMenuElement());
},_childInserted:function(d,c,b){a.RadContextMenu.callBaseMethod(this,"_childInserted",[d,c,b]);
if(b._shown){if(c._getWidth()>0||c.get_isSeparator()){a.RadMenu._adjustChildrenWidth(b);
}}},_attachShowHandlers:function(){var d=$telerik.isOpera?"mousedown":"contextmenu";
var c=this._getTargetElements();
for(var b=0;
b<c.length;
b++){$addHandler(c[b],d,this._elementContextMenu);
}$addHandler(this._getContextMenuElement(),d,this._elementContextMenu);
},_detachShowHandlers:function(){var e=$telerik.isOpera?"mousedown":"contextmenu";
var d=this._getTargetElements();
for(var b=0;
b<d.length;
b++){var c=d[b];
try{$removeHandler(c,e,this._elementContextMenu);
}catch(f){}}try{$removeHandler(this._getContextMenuElement(),e,this._elementContextMenu);
}catch(f){}},_documentClickHandler:function(c){var b=this._getContextMenuElement();
if(!$telerik.isDescendant(b,c.target)){this.close();
this._clicked=false;
this._hide(c);
}},_itemClickedHandler:function(b,c){if(!this.get_clickToOpen()){this._hide(c.get_domEvent());
}},_initializeAnimation:function(){this._determineExpandDirection();
var b=this._getAnimatedElement();
if(b){this._slide=new a.jSlide(b,this.get_expandAnimation(),this.get_collapseAnimation());
this._slide.initialize();
this._slide.set_direction(this._getSlideDirection());
this._collapseAnimationEndedDelegate=Function.createDelegate(this,this._onCollapseAnimationEnded);
this._slide.add_collapseAnimationEnded(this._collapseAnimationEndedDelegate);
this._expandAnimationStartedDelegate=Function.createDelegate(this,this._onExpandAnimationStarted);
this._slide.add_expandAnimationStarted(this._expandAnimationStartedDelegate);
this._expandAnimationEndedDelegate=Function.createDelegate(this,this._onExpandAnimationEnded);
this._slide.add_expandAnimationEnded(this._expandAnimationEndedDelegate);
}},_getRtlClassName:function(){var b=a.RadContextMenu.callBaseMethod(this,"_getRtlClassName");
return b+" RadMenu_Context_rtl";
},_getMainElement:function(){return this._getContextMenuElement();
},_getSlideDirection:function(){var b=this.get_defaultGroupSettings().get_expandDirection();
if(b==a.ExpandDirection.Auto){return null;
}return b;
},_getScrollWrapElement:function(){var b=this._getContextMenuElement();
if(!this._scrollWrapElement){if(this.get_defaultGroupSettings().get_height()||this.get_defaultGroupSettings().get_width()){this._scrollWrapElement=$telerik.getFirstChildByTagName(b,"div",0);
}}return this._scrollWrapElement;
},_getAnimatedElement:function(){if(!this._animatedElement){this._animatedElement=this._getScrollWrapElement()||this.get_childListElement();
}return this._animatedElement;
},_determineExpandDirection:function(){var b=this.get_defaultGroupSettings();
if(b.get_expandDirection()!=a.ExpandDirection.Auto){return;
}b.set_expandDirection(a.ExpandDirection.Down);
},_onExpandAnimationEnded:function(){},_onExpandAnimationStarted:function(){},_onCollapseAnimationEnded:function(){this._restoreZIndex();
},_getTargetElements:function(){if(this._targetElements==null){this._targetElements=[];
for(var b=0;
b<this._targets.length;
b++){this._addTargetElements(this._targets[b]);
}}return this._targetElements;
},_addTargetElements:function(c){switch(c.type){case a.ContextMenuTargetType.Document:this._addTargetElement(document);
break;
case a.ContextMenuTargetType.Control:case a.ContextMenuTargetType.Element:this._addTargetElement($get(c.id));
break;
case a.ContextMenuTargetType.TagName:var b=document.getElementsByTagName(c.tagName);
for(var d=0;
d<b.length;
d++){this._addTargetElement(b[d]);
}break;
}},_addTargetElement:function(b){if(b){this._targetElements[this._targetElements.length]=b;
}},_adjustPositionForScreenBoundaries:function(d,c){var b=a.RadMenu._getViewPortSize();
var e=this._getContextMenuElement();
c=Math.min(c,b.height-e.offsetHeight);
if(this.get_rightToLeft()){d=Math.max(0,d);
}else{d=Math.min(d,b.width-e.offsetWidth);
}if(isNaN(d)){d=0;
}if(isNaN(c)){c=0;
}this._getContextMenuElement().style.left=d+"px";
this._getContextMenuElement().style.top=c+"px";
},_detach:function(){if(!$telerik.isIE||document.readyState=="complete"||document.readyState=="interactive"){this._getContextMenuElement().parentNode.removeChild(this._getContextMenuElement());
var b=theForm||document.body;
b.insertBefore(this._getContextMenuElement(),b.firstChild);
this._detached=true;
}},_getContextMenuElement:function(){if(!this._contextMenuElement){this._contextMenuElement=$telerik.getFirstChildByTagName(this.get_element(),"div",0);
}return this._contextMenuElement;
},_isMainElementDescendant:function(b){return $telerik.isDescendant(this._getContextMenuElement(),b);
},attachContextMenu:function(){if(!this._detached){return;
}this._getContextMenuElement().parentNode.removeChild(this._getContextMenuElement());
this.get_element().insertBefore(this._getContextMenuElement(),$get(this.get_clientStateFieldID()));
this._detached=false;
},_getExtendedItemClickingEventArgs:function(b){return new a.RadContextMenuItemCancelEventArgs(b.get_item(),this._targetElement,b.get_domEvent());
},_getExtendedItemClickedEventArgs:function(b){return new a.RadContextMenuItemEventArgs(b.get_item(),this._targetElement,b.get_domEvent());
},_updateScrollWrapSize:function(){var b=this._getScrollWrapElement();
var c=this.get_childListElement();
if(!b){return;
}if(!b.style.height){b.style.height=c.offsetHeight+"px";
}b.style.width=c.offsetWidth+"px";
},_getAnimationContainer:function(){return this._getContextMenuElement();
},_initializeScroller:function(){var b=this._getScrollWrapElement();
if(b){this._scroller=new a.MenuItemScroller(this.get_childListElement(),a.ItemFlow.Vertical);
this._scroller.initialize();
}},_adjustRootItemsWidthOnShow:function(){var c=this.get_items();
var b=c.get_count();
for(var d=0;
d<b;
d++){var e=c.getItem(d);
if(e._adjustSiblingsWidthOnShow){e._adjustSiblingsWidth();
e._adjustSiblingsWidthOnShow=false;
return;
}}},_onTopArrowMouseDown:function(c){var b=this._extractItemFromDomElement(c.eventMapTarget);
if(b!=null){a.RadContextMenu.callBaseMethod(this,"_onTopArrowMouseDown",[c]);
return;
}this._onScrollArrowMouseDown(a.ArrowPosition.Top);
},_onTopArrowMouseUp:function(c){var b=this._extractItemFromDomElement(c.eventMapTarget);
if(b!=null){a.RadContextMenu.callBaseMethod(this,"_onTopArrowMouseDown",[c]);
return;
}this._onScrollArrowMouseUp(a.ArrowPosition.Top);
},_onTopArrowMouseOver:function(c){var b=this._extractItemFromDomElement(c.eventMapTarget);
if(b!=null){a.RadContextMenu.callBaseMethod(this,"_onTopArrowMouseOver",[c]);
return;
}this._onScrollArrowMouseOver(a.ArrowPosition.Top);
},_onTopArrowMouseOut:function(c){var b=this._extractItemFromDomElement(c.eventMapTarget);
if(b!=null){a.RadContextMenu.callBaseMethod(this,"_onTopArrowMouseOut",[c]);
return;
}this._onScrollArrowMouseOut(a.ArrowPosition.Top);
},_onBottomArrowMouseDown:function(c){var b=this._extractItemFromDomElement(c.eventMapTarget);
if(b!=null){a.RadContextMenu.callBaseMethod(this,"_onBottomArrowMouseDown",[c]);
return;
}this._onScrollArrowMouseDown(a.ArrowPosition.Bottom);
},_onBottomArrowMouseUp:function(c){var b=this._extractItemFromDomElement(c.eventMapTarget);
if(b!=null){a.RadContextMenu.callBaseMethod(this,"_onBottomArrowMouseUp",[c]);
return;
}this._onScrollArrowMouseUp(a.ArrowPosition.Bottom);
},_onBottomArrowMouseOver:function(c){var b=this._extractItemFromDomElement(c.eventMapTarget);
if(b!=null){a.RadContextMenu.callBaseMethod(this,"_onBottomArrowMouseOver",[c]);
return;
}this._onScrollArrowMouseOver(a.ArrowPosition.Bottom);
},_onBottomArrowMouseOut:function(c){var b=this._extractItemFromDomElement(c.eventMapTarget);
if(b!=null){a.RadContextMenu.callBaseMethod(this,"_onBottomArrowMouseOut",[c]);
return;
}this._onScrollArrowMouseOut(a.ArrowPosition.Bottom);
},_onLeftArrowMouseDown:function(c){var b=this._extractItemFromDomElement(c.eventMapTarget);
if(b!=null){a.RadContextMenu.callBaseMethod(this,"_onLeftArrowMouseDown",[c]);
return;
}this._onScrollArrowMouseDown(a.ArrowPosition.Left);
},_onLeftArrowMouseUp:function(c){var b=this._extractItemFromDomElement(c.eventMapTarget);
if(b!=null){a.RadContextMenu.callBaseMethod(this,"_onLeftArrowMouseUp",[c]);
return;
}this._onScrollArrowMouseUp(a.ArrowPosition.Left);
},_onLeftArrowMouseOver:function(c){var b=this._extractItemFromDomElement(c.eventMapTarget);
if(b!=null){a.RadContextMenu.callBaseMethod(this,"_onLeftArrowMouseOver",[c]);
return;
}this._onScrollArrowMouseOver(a.ArrowPosition.Left);
},_onLeftArrowMouseOut:function(c){var b=this._extractItemFromDomElement(c.eventMapTarget);
if(b!=null){a.RadContextMenu.callBaseMethod(this,"_onLeftArrowMouseOut",[c]);
return;
}this._onScrollArrowMouseOut(a.ArrowPosition.Left);
},_onRightArrowMouseDown:function(c){var b=this._extractItemFromDomElement(c.eventMapTarget);
if(b!=null){a.RadContextMenu.callBaseMethod(this,"_onRightArrowMouseDown",[c]);
return;
}this._onScrollArrowMouseDown(a.ArrowPosition.Right);
},_onRightArrowMouseUp:function(c){var b=this._extractItemFromDomElement(c.eventMapTarget);
if(b!=null){a.RadContextMenu.callBaseMethod(this,"_onRightArrowMouseUp",[c]);
return;
}this._onScrollArrowMouseUp(a.ArrowPosition.Right);
},_onRightArrowMouseOver:function(c){var b=this._extractItemFromDomElement(c.eventMapTarget);
if(b!=null){a.RadContextMenu.callBaseMethod(this,"_onRightArrowMouseOver",[c]);
return;
}this._onScrollArrowMouseOver(a.ArrowPosition.Right);
},_onRightArrowMouseOut:function(c){var b=this._extractItemFromDomElement(c.eventMapTarget);
if(b!=null){a.RadContextMenu.callBaseMethod(this,"_onRightArrowMouseOut",[c]);
return;
}this._onScrollArrowMouseOut(a.ArrowPosition.Right);
},_onScrollArrowMouseDown:function(){if(!this._scroller){return;
}this._scroller.changeScrollSpeed(a.ScrollerSpeed.Fast);
},_onScrollArrowMouseUp:function(){if(!this._scroller){return;
}this._scroller.changeScrollSpeed(a.ScrollerSpeed.Slow);
},_onScrollArrowMouseOver:function(b){if(!this._scroller){return;
}var c=1;
if(b==a.ArrowPosition.Top||b==a.ArrowPosition.Left){c=-1;
}this._scroller.startScroll(a.ScrollerSpeed.Slow,c);
},_onScrollArrowMouseOut:function(){if(!this._scroller){return;
}this._scroller.stopScroll();
},_elementContextMenu:function(b){if($telerik.isDescendantOrSelf(this._getContextMenuElement(),b.target)){$telerik.cancelRawEvent(b);
return false;
}if($telerik.isOpera){if(b.button!=2){return;
}}this.show(b);
},_showAt:function(c,b,d){a.RadContextMenu.hideAll();
if(!a.RadContextMenu._getAllHidden()){return;
}this._shown=true;
if(!this._detached){this._detach();
this._getContextMenuElement().style.visibility="hidden";
this._getContextMenuElement().style.display="block";
this.repaint();
}this._slide.show();
this._adjustRootItemsWidthOnShow();
this._updateScrollWrapSize();
this._slide.updateSize();
if(this._rightToLeft){c-=this._getContextMenuElement().offsetWidth;
}this._getContextMenuElement().style.left=c+"px";
this._getContextMenuElement().style.top=b+"px";
if(this.get_enableScreenBoundaryDetection()){this._adjustPositionForScreenBoundaries(c,b);
}if(this._scroller){this._scroller.updateState();
}this._getContextMenuElement().style.visibility="visible";
this._slide.expand();
this.raise_shown(new a.RadContextMenuShownEventArgs(this._targetElement,d||null));
},_hide:function(d){if(!this._shown){return;
}var b=new a.RadContextMenuCancelEventArgs(this._targetElement,d||null);
this.raise_hiding(b);
if(b.get_cancel()){return;
}this._shown=false;
this._slide.collapse();
this.raise_hidden(new a.RadContextMenuEventArgs(d||null));
this._targetElement=null;
this._clicked=false;
if(this._focusedItem){this._focusedItem._doBlur();
}var c=this.get_openedItem();
if(c){c.close();
}},get_childListElement:function(){if(this._getScrollWrapElement()){this._childListElement=$telerik.getFirstChildByTagName(this._getScrollWrapElement(),"ul",0);
}if(!this._childListElement){this._childListElement=$telerik.getFirstChildByTagName(this._getContextMenuElement(),"ul",0);
}return this._childListElement;
},set_targets:function(b){this._targets=b;
},get_targets:function(){return this._targets;
},get_contextMenuElement:function(){return this._getContextMenuElement();
},_adjustRootItemWidth:function(){},show:function(c){if(this._shown){this._hide();
}this._targetElement=c.target;
var d=new a.RadContextMenuShowingEventArgs(this._targetElement,c||null);
this.raise_showing(d);
if(d.get_cancel()){return;
}var b=$telerik.getDocumentRelativeCursorPosition(c);
this._showAt(b.left,b.top,c);
$telerik.cancelRawEvent(c);
},showAt:function(c,b){var d=new a.RadContextMenuShowingEventArgs();
this.raise_showing(d);
if(d.get_cancel()){return;
}this._showAt(c,b,null);
},hide:function(){this._hide(null);
},add_showing:function(b){this.get_events().addHandler("showing",b);
},remove_showing:function(b){this.get_events().removeHandler("showing",b);
},raise_showing:function(b){if(this._fireEvents){this.raiseEvent("showing",b);
}},raise_hiding:function(b){if(this._fireEvents){this.raiseEvent("hiding",b);
}},add_shown:function(b){this.get_events().addHandler("shown",b);
},remove_shown:function(b){this.get_events().removeHandler("shown",b);
},raise_shown:function(b){if(this._fireEvents){this.raiseEvent("shown",b);
}},add_hiding:function(b){this.get_events().addHandler("hiding",b);
},remove_hiding:function(b){this.get_events().removeHandler("hiding",b);
},add_hidden:function(b){this.get_events().addHandler("hidden",b);
},remove_hidden:function(b){this.get_events().removeHandler("hidden",b);
},raise_hidden:function(b){if(this._fireEvents){this.raiseEvent("hidden",b);
}}};
a.RadContextMenu.registerClass("Telerik.Web.UI.RadContextMenu",a.RadMenu);
})();
